<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人资料</title>
    <link href="../css/Own_Buy.css" rel="stylesheet" />
    <link rel="stylesheet" href="../css/Own_ib_Paging.css" media="screen" type="text/css" />
    <script src="../js/jquery-2.1.1.min.js"></script>
    <script src="../js/jquery-3.4.1.min.js"></script>
</head>
<body>
<div id="container">
    <div id="content1">
    </div>

    <div id="content2">
    </div>

    <div id="content3">
        <ul id="menu">
        </ul>
    </div>
</div>

<script type="text/javascript">
    var DataALL = [];
    var count;

    $(document).ready(function ()
    {
        var message = JSON.parse(sessionStorage.getItem("head_message"));
        var par = {"Uid": message.Uid};
        $.get("/commodity/own", par, function (data)
        {
            var x = 0;
            for (var dataindex in data)
            {
                DataALL[x]=data[dataindex];
                x++;
            }
            count = x;
            if(count<=10) {var refresh = count;}
            else {var refresh = 10;}
            for(var m=0;m<refresh;m++)
            {
                var datatrue = DataALL[m];
                if(m%2==0)
                {
                    var strComL = "<div class=\"content\" onclick=\"ComPage("+datatrue.Cid+")\">\n" +
                        "            <div class=\"goodsL\">\n" +
                        "                <img class=\"img1\" src=\"../img/commodity_img/"+datatrue.Image+"\">\n" +
                        "            </div>\n" +
                        "            <div class=\"goodsM\">\n" +
                        "                <div class=\"banner\"><input type=\"text\" class=\"input1\" value=\""+datatrue.Cname+"\"></div>\n" +
                        "                <div class=\"middle\"><textarea class=\"input2\">"+datatrue.Intro+"</textarea></div>\n" +
                        "                <div class=\"footer\"><input type=\"text\" class=\"input3\" value=\"￥"+datatrue.Price+"\"></div>\n" +
                        "            </div>\n" +
                        "        </div>";
                    $("#content1").append(strComL);
                }
                else
                {
                    var strComR = "<div class=\"content\" onclick=\"ComPage("+datatrue.Cid+")\">\n" +
                        "            <div class=\"goodsL\">\n" +
                        "                <img class=\"img1\" src=\"../img/commodity_img/"+datatrue.Image+"\">\n" +
                        "            </div>\n" +
                        "            <div class=\"goodsM\">\n" +
                        "                <div class=\"banner\"><input type=\"text\" class=\"input1\" value=\""+datatrue.Cname+"\"></div>\n" +
                        "                <div class=\"middle\"><textarea class=\"input2\">"+datatrue.Intro+"</textarea></div>\n" +
                        "                <div class=\"footer\"><input type=\"text\" class=\"input3\" value=\"￥"+datatrue.Price+"\"></div>\n" +
                        "            </div>\n" +
                        "        </div>";
                    $("#content2").append(strComR);
                }
            }

            var j = Math.ceil(count/10);
            if(j!==0)
            {
                var strFirst ="<li><a onclick=\"ChoosePage(1)\">首页</a></li>";
                $("#menu").append(strFirst);
                for ( var k=1;k<=j;k++)
                {
                    var str = "<li><a onclick=\"ChoosePage("+k+")\">"+k+"</a></li>";
                    $("#menu").append(str);
                }
                var strEnd ="<li><a onclick=\"ChoosePage("+j+")\">尾页</a></li>";
                $("#menu").append(strEnd);
            }
            else
            {
                $("#menu").append("<li>！没有买过任何商品！</li>");
            }
        })
    })

    function ChoosePage(page)
    {
        $("#content1").empty();
        $("#content2").empty();

        var t = page-1;
        var q = count-(t*10);
        for(var h=0;h<q;h++)
        {
            var datatrue = DataALL[t+h];
            if(h%2==0)
            {
                var strComL = "<div class=\"content\" onclick=\"ComPage("+datatrue.Cid+")\">\n" +
                    "            <div class=\"goodsL\">\n" +
                    "                <img class=\"img1\" src=\"../img/commodity_img/"+datatrue.Image+"\">\n" +
                    "            </div>\n" +
                    "            <div class=\"goodsM\">\n" +
                    "                <div class=\"banner\"><input type=\"text\" class=\"input1\" value=\""+datatrue.Cname+"\"></div>\n" +
                    "                <div class=\"middle\"><textarea class=\"input2\">"+datatrue.Intro+"</textarea></div>\n" +
                    "                <div class=\"footer\"><input type=\"text\" class=\"input3\" value=\"￥"+datatrue.Price+"\"></div>\n" +
                    "            </div>\n" +
                    "            <div class=\"goodsR\">\n" +
                    "                <div class=\"left\"><img class=\"img2\"></div>\n" +
                    "                <div class=\"right\"><img class=\"img3\"></div>\n" +
                    "            </div>\n" +
                    "        </div>";
                $("#content1").append(strComL);
            }
            else
            {
                var strComR = "<div class=\"content\" onclick=\"ComPage("+datatrue.Cid+")\">\n" +
                    "            <div class=\"goodsL\">\n" +
                    "                <img class=\"img1\" src=\"../img/commodity_img/"+datatrue.Image+"\">\n" +
                    "            </div>\n" +
                    "            <div class=\"goodsM\">\n" +
                    "                <div class=\"banner\"><input type=\"text\" class=\"input1\" value=\""+datatrue.Cname+"\"></div>\n" +
                    "                <div class=\"middle\"><textarea class=\"input2\">"+datatrue.Intro+"</textarea></div>\n" +
                    "                <div class=\"footer\"><input type=\"text\" class=\"input3\" value=\"￥"+datatrue.Price+"\"></div>\n" +
                    "            </div>\n" +
                    "            <div class=\"goodsR\">\n" +
                    "                <div class=\"left\"><img class=\"img2\"></div>\n" +
                    "                <div class=\"right\"><img class=\"img3\"></div>\n" +
                    "            </div>\n" +
                    "        </div>";
                $("#content2").append(strComR);
            }
        }
    }

    function ComPage(id)
    {
        window.location.href="Own_look.html?"+id;
    }
</script>

</body>
</html>